* @Title: GtkFrame
*
* The frame widget is a bin that surrounds its child with a decorative
- * frame and an optional label. If present, the label is drawn in a gap
- * in the top side of the frame. The position of the label can be
- * controlled with gtk_frame_set_label_align().
+ * frame and an optional label. If present, the label is drawn inside
+ * the top edge of the frame. The horizontal position of the label can
+ * be controlled with gtk_frame_set_label_align().
*
* # GtkFrame as GtkBuildable
*
gint16 shadow_type;
gfloat label_xalign;
- gfloat label_yalign;
- /* Properties */
GtkAllocation child_allocation;
GtkAllocation label_allocation;
PROP_0,
PROP_LABEL,
PROP_LABEL_XALIGN,
- PROP_LABEL_YALIGN,
PROP_SHADOW_TYPE,
PROP_LABEL_WIDGET,
LAST_PROP
0.0,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- frame_props[PROP_LABEL_YALIGN] =
- g_param_spec_float ("label-yalign",
- P_("Label yalign"),
- P_("The vertical alignment of the label"),
- 0.0, 1.0,
- 0.5,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
-
frame_props[PROP_SHADOW_TYPE] =
g_param_spec_enum ("shadow-type",
P_("Frame shadow"),
priv->label_widget = NULL;
priv->shadow_type = GTK_SHADOW_ETCHED_IN;
priv->label_xalign = 0.0;
- priv->label_yalign = 0.5;
}
static void
GParamSpec *pspec)
{
GtkFrame *frame = GTK_FRAME (object);
- GtkFramePrivate *priv = frame->priv;
switch (prop_id)
{
gtk_frame_set_label (frame, g_value_get_string (value));
break;
case PROP_LABEL_XALIGN:
- gtk_frame_set_label_align (frame, g_value_get_float (value),
- priv->label_yalign);
+ gtk_frame_set_label_align (frame, g_value_get_float (value));
break;
- case PROP_LABEL_YALIGN:
- gtk_frame_set_label_align (frame, priv->label_xalign,
- g_value_get_float (value));
- break;
case PROP_SHADOW_TYPE:
gtk_frame_set_shadow_type (frame, g_value_get_enum (value));
break;
case PROP_LABEL_XALIGN:
g_value_set_float (value, priv->label_xalign);
break;
- case PROP_LABEL_YALIGN:
- g_value_set_float (value, priv->label_yalign);
- break;
case PROP_SHADOW_TYPE:
g_value_set_enum (value, priv->shadow_type);
break;
* @xalign: The position of the label along the top edge
* of the widget. A value of 0.0 represents left alignment;
* 1.0 represents right alignment.
- * @yalign: The y alignment of the label. A value of 0.0 aligns under
- * the frame; 1.0 aligns above the frame. If the values are exactly
- * 0.0 or 1.0 the gap in the frame won’t be painted because the label
- * will be completely above or below the frame.
*
- * Sets the alignment of the frame widget’s label. The
- * default values for a newly created frame are 0.0 and 0.5.
+ * Sets the X alignment of the frame widget’s label. The
+ * default value for a newly created frame is 0.0.
**/
void
gtk_frame_set_label_align (GtkFrame *frame,
- gfloat xalign,
- gfloat yalign)
+ gfloat xalign)
{
GtkFramePrivate *priv;
priv = frame->priv;
xalign = CLAMP (xalign, 0.0, 1.0);
- yalign = CLAMP (yalign, 0.0, 1.0);
g_object_freeze_notify (G_OBJECT (frame));
if (xalign != priv->label_xalign)
g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_XALIGN]);
}
- if (yalign != priv->label_yalign)
- {
- priv->label_yalign = yalign;
- g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_LABEL_YALIGN]);
- }
-
g_object_thaw_notify (G_OBJECT (frame));
gtk_widget_queue_resize (GTK_WIDGET (frame));
}
/**
* gtk_frame_get_label_align:
* @frame: a #GtkFrame
- * @xalign: (out) (allow-none): location to store X alignment of
- * frame’s label, or %NULL
- * @yalign: (out) (allow-none): location to store X alignment of
- * frame’s label, or %NULL
*
- * Retrieves the X and Y alignment of the frame’s label. See
+ * Retrieves the X alignment of the frame’s label. See
* gtk_frame_set_label_align().
**/
-void
-gtk_frame_get_label_align (GtkFrame *frame,
- gfloat *xalign,
- gfloat *yalign)
+gfloat
+gtk_frame_get_label_align (GtkFrame *frame)
{
- GtkFramePrivate *priv;
-
- g_return_if_fail (GTK_IS_FRAME (frame));
-
- priv = frame->priv;
+ g_return_val_if_fail (GTK_IS_FRAME (frame), 0.0);
- if (xalign)
- *xalign = priv->label_xalign;
- if (yalign)
- *yalign = priv->label_yalign;
+ return frame->priv->label_xalign;
}
/**
spin_xalign_cb (GtkSpinButton *spin, GtkFrame *frame)
{
gdouble xalign;
- gfloat yalign;
xalign = double_normalize (gtk_spin_button_get_value (spin));
- gtk_frame_get_label_align (frame, NULL, &yalign);
- gtk_frame_set_label_align (frame, xalign, yalign);
+ gtk_frame_set_label_align (frame, xalign);
}
-#if 0
-static void
-spin_yalign_cb (GtkSpinButton *spin, GtkFrame *frame)
-{
- gdouble yalign;
- gfloat xalign;
-
- yalign = double_normalize (gtk_spin_button_get_value (spin));
- gtk_frame_get_label_align (frame, &xalign, NULL);
- gtk_frame_set_label_align (frame, xalign, yalign);
-}
-#endif
-
static void
draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
{
GtkBox *vbox;
GtkFrame *frame;
GtkGrid *grid;
- gfloat xalign, yalign;
+ gfloat xalign;
gboolean draw_border;
gtk_init ();
gtk_grid_set_column_spacing (grid, 6);
gtk_box_pack_start (vbox, GTK_WIDGET (grid));
- gtk_frame_get_label_align (frame, &xalign, &yalign);
+ xalign = gtk_frame_get_label_align (frame);
/* Spin to control :label-xalign */
widget = gtk_label_new ("label xalign:");
g_signal_connect (widget, "value-changed", G_CALLBACK (spin_xalign_cb), frame);
gtk_grid_attach (grid, widget, 1, 0, 1, 1);
-/* Frame:label-yalign does nothing since the border node was removed */
-#if 0
- /* Spin to control :label-yalign */
- widget = gtk_label_new ("label yalign:");
- gtk_grid_attach (grid, widget, 0, 1, 1, 1);
-
- widget = gtk_spin_button_new_with_range (0.0, 1.0, 0.1);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), yalign);
- g_signal_connect (widget, "value-changed", G_CALLBACK (spin_yalign_cb), frame);
- gtk_grid_attach (grid, widget, 1, 1, 1, 1);
-#endif
-
/* Spin to control vertical padding */
widget = gtk_label_new ("vertical padding:");
gtk_grid_attach (grid, widget, 0, 1, 1, 1);